|
|
|
|
|
|
|
Dim sFName As String
Dim sLName As String
sFName = txtFirstname
sLName = txtLastName |
|
|
|
|
|
|
|
|
You can then store the combination of the last name and first name values in another variable and use it to update the txtEntireName box, like this: |
|
|
|
|
|
|
|
|
Dim sName As String
sName = txtFirstName & " " & txtLastName
txtEntireName = sName |
|
|
|
|
|
|
|
|
Of course, because text boxes themselves can be treated as variables (via the control's default property), you can achieve the same result without having to declare any variables, as in this line: |
|
|
|
|
|
|
|
|
txtEntireName = txtFirstname & " " & txtlastName |
|
|
|
|
|
|
|
|
The preceding line of code is more efficient because it does not require dimensioning variables. However, when you are dealing with code that repeatedly accesses a property of a control (such as a For loop), sometimes storing a property in a temporary variable is more efficient. |
|
|
|
|
|
|
|
|
Processing numerical data is one of the key activities of many computer programs. Mathematical operations determine customer bills, interest due on savings or credit card balances, average scores for class tests, and many other bits of information. Visual Basic supports a number of different math operators that you can use in program statements. These operations and the Visual Basic symbol for each operation are summarized in Table 9.2. The operations are then described in detail in the following sections. |
|
|
|
|
| Table 9.2 Math Operations and the Corresponding Visual Basic Symbol | | Operation | Operator | | Addition | + | | Subtraction | - | | Multiplication | * | | Division | / | | Integer division | \ | | Modulus | mod | | Exponentiation | ^ |
|
|
|